;--------------------------------

; The name of the installer
Name "Xyne"

; The file to write
OutFile "xyne_install.exe"

; The default installation directory
InstallDir $PROGRAMFILES\Xyne

; Registry key to check for directory (so if you install again, it will 
; overwrite the old one automatically)
InstallDirRegKey HKLM "Software\Xyne" "Install_Dir"

;--------------------------------

; Pages

Page directory
Page instfiles

UninstPage uninstConfirm
UninstPage instfiles

;--------------------------------

; The stuff to install
Section "Xyne" ;No components page, name is not important

  SectionIn RO

  ; Set output path to the installation directory.
  SetOutPath $INSTDIR
  
  ; Put file there
  File xyne.exe
  File jpeg.dll
  File libpng12-0.dll
  File libtiff-3.dll
  File SDL.dll
  File SDL_gfx.dll
  File SDL_image.dll
  File zlib1.dll
  File cicle_fina.ttf
  File knight.ttf
  File SDL_ttf.dll
  File libfreetype-6.dll

  ; Set output path to the image installation directory.
  SetOutPath $INSTDIR\img

  File img\bg.png
  File img\simple_gem_black.png
  File img\simple_gem_blue.png
  File img\simple_gem_green.png
  File img\simple_gem_red.png
  File img\simple_gem_white.png
  File img\simple_gem_yellow.png
  File img\sample_card_image.png
  File img\card_details_background.png
  File img\card_normal_background.png
  File img\time_region_bg.png
  File img\gem_hover.png

  ; Set output path to the image numbers installation directory.
  SetOutPath $INSTDIR\img\numbers
  File img\numbers\0.png
  File img\numbers\1.png
  File img\numbers\2.png
  File img\numbers\3.png
  File img\numbers\4.png
  File img\numbers\5.png
  File img\numbers\6.png
  File img\numbers\7.png
  File img\numbers\8.png
  File img\numbers\9.png
  File img\numbers\colon.png

  ; Set output path to the installation directory.
  SetOutPath $INSTDIR

  ; Write the installation path into the registry
  WriteRegStr HKLM SOFTWARE\Xyne "Install_Dir" "$INSTDIR"
  
  ; Write the uninstall keys for Windows
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Xyne" "DisplayName" "Xyne"
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Xyne" "UninstallString" '"$INSTDIR\uninstall.exe"'
  WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Xyne" "NoModify" 1
  WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Xyne" "NoRepair" 1
  WriteUninstaller "uninstall.exe"
  
SectionEnd ; end the section

;--------------------------------

Section "Start Menu Shortcuts"

  SetShellVarContext all

  CreateDirectory "$SMPROGRAMS\Xyne"
  CreateShortCut "$SMPROGRAMS\Xyne\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0
  CreateShortCut "$SMPROGRAMS\Xyne\Xyne.lnk" "$INSTDIR\xyne.exe" "" "$INSTDIR\xyne.exe" 0
  
SectionEnd

;--------------------------------

; Uninstaller

Section "Uninstall"
  
  SetShellVarContext all

  ; Remove registry keys
  DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Xyne"
  DeleteRegKey HKLM SOFTWARE\Xyne

  ; Remove files and uninstaller
  Delete $INSTDIR\xyne.exe
  Delete $INSTDIR\jpeg.dll
  Delete $INSTDIR\libpng12-0.dll
  Delete $INSTDIR\libtiff-3.dll
  Delete $INSTDIR\SDL.dll
  Delete $INSTDIR\SDL_gfx.dll
  Delete $INSTDIR\SDL_image.dll
  Delete $INSTDIR\zlib1.dll
  Delete $INSTDIR\cicle_fina.ttf
  Delete $INSTDIR\knight.ttf
  Delete $INSTDIR\SDL_ttf.dll
  Delete $INSTDIR\libfreetype-6.dll
  Delete $INSTDIR\uninstall.exe
  Delete $INSTDIR\stdout.txt
  Delete $INSTDIR\img\bg.png
  Delete $INSTDIR\img\simple_gem_black.png
  Delete $INSTDIR\img\simple_gem_blue.png
  Delete $INSTDIR\img\simple_gem_green.png
  Delete $INSTDIR\img\simple_gem_red.png
  Delete $INSTDIR\img\simple_gem_white.png
  Delete $INSTDIR\img\simple_gem_yellow.png
  Delete $INSTDIR\img\numbers\0.png
  Delete $INSTDIR\img\numbers\1.png
  Delete $INSTDIR\img\numbers\2.png
  Delete $INSTDIR\img\numbers\3.png
  Delete $INSTDIR\img\numbers\4.png
  Delete $INSTDIR\img\numbers\5.png
  Delete $INSTDIR\img\numbers\6.png
  Delete $INSTDIR\img\numbers\7.png
  Delete $INSTDIR\img\numbers\8.png
  Delete $INSTDIR\img\numbers\9.png
  Delete $INSTDIR\img\numbers\colon.png
  Delete $INSTDIR\img\sample_card_image.png
  Delete $INSTDIR\img\card_details_background.png
  Delete $INSTDIR\img\card_normal_background.png
  Delete $INSTDIR\img\time_region_bg.png
  Delete $INSTDIR\img\gem_hover.png

  ; Remove shortcuts, if any
  Delete "$SMPROGRAMS\Xyne\*.*"

  ; Remove directories used
  RMDir "$SMPROGRAMS\Xyne"
  RMDir "$INSTDIR\img\numbers"
  RMDir "$INSTDIR\img"
  RMDir "$INSTDIR"

SectionEnd
